#include "support_common.h"
#include "common.h"
#include "speaker_pwm.h"


// Flash the LED's in the proper sequence per the project requirements.
/*
static void flash_led_sequence(int p_delay)
{
	int direction = dipsw_onoff_poll();
	int i;
	for(i=1; i <= 4; i++)
	{
		// Turn LED ON
		uc_led_on( (direction == 1) ? 5-i: i );
		dtim0_delay(p_delay);
		
		// Turn LED OFF
		uc_led_off( (direction == 1) ? 5-i: i );
		dtim0_delay(p_delay);
		
		if(direction != dipsw_onoff_poll())
		{
			i = 4 - i;
			direction = !direction;
		}
	}
}

*/
// Calls uc_dipsw_init() to initialize the DIP switch, uc_led_init() to initialize the LED's,
// and dtim0_init() to initialize DTIM0.
static void init()
{
	//uc_dipsw_init();
	gpio_port_tc_init();
	uc_led_all_off();
	gpt_init();
	pwm_init();
	pit_init();
	
	//uninhibit all here:
	int_uninhibit_all();
	//(*(vuint8 *)(0x80E)) |= (2<<7);
	
	
}

// Calls init() to initialize the hardware. Then drops into an infinite loop calling
// flash_led_equence() forever.
int main()
{
	init();
	//uc_led_all_off();
	
	//play_next();
	while (1)
	{
		
		//flash_led_sequence( dipsw_delay_poll() );
		
	}
	
	return 0;
}